<?php
/**
 * Created by JetBrains PhpStorm.
 * User: mokhov
 * Date: 19.03.13
 * Time: 17:44
 * To change this template use File | Settings | File Templates.
 */

class Engine_Grid_Action {

    protected $id;
    protected $name;
    protected $href;
    protected $conditions = array();

    public function __construct(array $params) {
        if (is_array($params)) {
            foreach ($params as $key=>$param) {
                $this->$key = $param;
            }
        } else {
            throw new Exception('Error create action. Params must be array',404);
        }
    }

    public function setConditions($conditions)
    {
        $this->conditions = $conditions;
    }

    public function getConditions()
    {
        return $this->conditions;
    }

    public function setHref($href)
    {
        $this->href = $href;
    }

    public function getHref()
    {
        return $this->href;
    }

    public function prepareHref(array $data){
        $href = $this->href;
        foreach ($data as $key=>$value) {
             $href = str_replace('%' . $key . '%', $value, $href );
        }
        return $href;
    }

    public function setName($name)
    {
        $this->name = $name;
    }

    public function getName()
    {
        return $this->name;
    }



}